<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="field[@type = 'password' and parent::doctype]" mode="dtf_error">
		<xsl:if test="../../pass_info/error[@field_name = current()/@name]">
			<xsl:choose>
				<xsl:when test="../../pass_info/error[@field_name = current()/@name and @name = 'UNFILLED']">
					<div class="error">
						<span>Пароль необходимо заполнить</span>
					</div>
				</xsl:when>
				<xsl:when test="../../pass_info/error[@field_name = current()/@name and @name = 'TOO_SHORT']">
					<div class="error">
						<span>
							<xsl:text>Строка слишком короткая. Минимально допустимая длина </xsl:text>
							<xsl:value-of select="@min_length"/>
							<xsl:text> </xsl:text>
							<xsl:call-template name="count_case">
								<xsl:with-param name="number" select="@min_length"/>
								<xsl:with-param name="word_ns" select="' символ'"/>
								<xsl:with-param name="word_gs" select="' символа'"/>
								<xsl:with-param name="word_ap" select="' символов'"/>
							</xsl:call-template>
							<xsl:text>, а у Вас </xsl:text>
							<xsl:value-of select="../../pass_info/error[@field_name = current()/@name and @name = 'TOO_SHORT']"/>
						</span>
					</div>
				</xsl:when>
				<xsl:when test="../../pass_info/error[@field_name = current()/@name and @name = 'TOO_LONG']">
					<div class="error">
						<span>
							<xsl:text>Строка слишком длинная. Максимально допустимая длина </xsl:text>
							<xsl:value-of select="@max_length"/>
							<xsl:text> </xsl:text>
							<xsl:call-template name="count_case">
								<xsl:with-param name="number" select="@max_length"/>
								<xsl:with-param name="word_ns" select="' символ'"/>
								<xsl:with-param name="word_gs" select="' символа'"/>
								<xsl:with-param name="word_ap" select="' символов'"/>
							</xsl:call-template>
							<xsl:text>, а у Вас </xsl:text>
							<xsl:value-of select="../../pass_info/error[@field_name = current()/@name and @name = 'TOO_LONG']"/>
						</span>
					</div>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
	<xsl:template match="field[@type = 'password' and parent::doctype]" mode="dtf_password_draw_warning">
		<xsl:variable name="is_new" select="parent::doctype/@action = 'create'"/>
		<xsl:variable name="document_field" select="../../document[@doctype_name = current()/parent::doctype/@name]/field[@name = current()/@name]"/>
		<xsl:if test="not($is_new) or not(../../pass_info/error[@field_name = current()/@name])">
			<div class="comment-">
				<xsl:if test="not($is_new) and not($document_field/@is_blank = 1)">Оставьте поле пустым, чтобы не менять пароль</xsl:if>
				<xsl:if test="not(../../pass_info/error[@field_name = current()/@name])">
					<xsl:if test="not($is_new)">. </xsl:if>
					<xsl:text>Минимальная длина &#8212; </xsl:text>
					<xsl:value-of select="@min_length"/>
					<xsl:text> </xsl:text>
					<xsl:call-template name="count_case">
						<xsl:with-param name="number" select="@min_length"/>
						<xsl:with-param name="word_ns" select="' символ'"/>
						<xsl:with-param name="word_gs" select="' символа'"/>
						<xsl:with-param name="word_ap" select="' символов'"/>
					</xsl:call-template>
				</xsl:if>
			</div>
		</xsl:if>
	</xsl:template>
	<xsl:template match="field[@type = 'password' and parent::doctype]" mode="dtf_error_2">
		<xsl:if test="../../pass_info/error[@field_name = current()/@name]">
			<xsl:choose>
				<xsl:when test="../../pass_info/error[@field_name = current()/@name and @name = 'PASSWORDS_NOT_EQUAL']">
					<div class="error">
						<span>Введённые пароли не совпадают</span>
					</div>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
